package com.zp.datax.core.function;

import java.util.function.Consumer;

/**
 * 自定义函数接口
 * Created by bruce on 2018/12/18.
 */
@FunctionalInterface
public interface ConsumerWrapper<T, E extends Exception> {


    void accept(T t) throws E;

    /**
     * 处理往外抛异常
     *
     * @param after
     * @return
     */
    default Consumer<T> andThen(Consumer<? super T> after) {
        return t -> {
            try {
                accept(t);
                after.accept(t);
            } catch (Exception e) {
                throw new FunctionException(e);
            }
        };
    }
}

